import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class FriendEntity {
  FriendEntity({
    this.friend_name,
    this.phone,
    this.remark,
    this.picurl,
  });

  factory FriendEntity.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : FriendEntity(
          friend_name: asT<String>(jsonRes['friend_name']),
          phone: asT<String>(jsonRes['phone']),
          remark: asT<String>(jsonRes['remark']),
          picurl: asT<String>(jsonRes['picurl']),
        );

  String friend_name;
  String phone;
  String remark;
  String picurl;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'friend_name': friend_name,
        'phone': phone,
        'remark': remark,
        'picurl': picurl,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}
